package studio.wetrack.dinner.logtime;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Service;

/**
 * Created by zhanghong on 2017/9/23.
 */
@Aspect
@Service
public class LogtimeProcessor {

    @Around(value = "execution(* *.*(..)) && @annotation(Logtime)")
    public void logTime(ProceedingJoinPoint joinPoint) throws Throwable {
        long startTime = System.currentTimeMillis();
        joinPoint.proceed();
        long executionTime = System.currentTimeMillis() - startTime;
        System.out.printf("%s executing time %d ms\n", joinPoint.getSignature().toShortString(),executionTime);

    }
}
